home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue56 / Clinic / SBarU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-25  |  1.3 KB  |  58 lines

  1. unit SBarU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ComCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Bar: TStatusBar;
  12.     ImageList1: TImageList;
  13.     Timer1: TTimer;
  14.     procedure FormCreate(Sender: TObject);
  15.     procedure BarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
  16.       const Rect: TRect);
  17.     procedure Timer1Timer(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. {$R *.DFM}
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32. begin
  33.   //Ensure that the timer's event handler is
  34.   //triggered as soon as the form is created
  35.   if Assigned(Timer1.OnTimer) then
  36.     Timer1.OnTimer(Timer1)
  37. end;
  38.  
  39. procedure TForm1.BarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
  40.   const Rect: TRect);
  41. const
  42.   //Start with the first image
  43.   Index: Integer = 0;
  44. begin
  45.   //Draw image on the status panel
  46.   ImageList1.Draw(Bar.Canvas, Rect.Left, Rect.Top, Index);
  47.   //Make sure a different image is used next time
  48.   Index := Succ(Index) mod ImageList1.Count
  49. end;
  50.  
  51. procedure TForm1.Timer1Timer(Sender: TObject);
  52. begin
  53.   //Get status bar to redraw itself
  54.   Bar.Invalidate
  55. end;
  56.  
  57. end.
  58.